package com.atguigu.gmall.weball.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.feign.order.OrderFeignClient;
import com.atguigu.gmall.order.vo.OrderConfirmVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * @Author:lyd
 * @Date:2023/9/3 22:52
 * @Version:1.0
 * @Description
 **/
@Controller
public class OrderController {


    @Autowired
    OrderFeignClient orderFeignClient;
    @GetMapping("/trade.html")
    public String trade(Model model) {

        Result<OrderConfirmVo> orderConfirmData = orderFeignClient.getOrderConfirmData();

        //订单确认页： 远程调用订单获取
        OrderConfirmVo data = orderConfirmData.getData();

        model.addAttribute("detailArrayList",data.getDetailArrayList());
        model.addAttribute("totalNum",data.getTotalNum());
        model.addAttribute("totalAmount",data.getTotalAmount());
        model.addAttribute("userAddressList",data.getUserAddressList());
        model.addAttribute("tradeNo",data.getTradeNo());
        //用户的订单页面
        return "order/trade";
    }
}
